package com.xiaoshuidi.cloud.module.bpm.service.reserveticket;

import java.time.LocalDate;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.*;

import com.xiaoshuidi.cloud.framework.security.core.LoginUser;
import com.xiaoshuidi.cloud.module.bpm.controller.admin.reserveticket.vo.*;
import com.xiaoshuidi.cloud.module.bpm.controller.app.reserveticket.vo.MyReserveTicketPageRespVO;
import com.xiaoshuidi.cloud.module.bpm.controller.app.reserveticket.vo.ReserveCreateReqVO;
import com.xiaoshuidi.cloud.module.bpm.dal.dataobject.reserveticket.ReserveTicketDO;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import lombok.NonNull;

/**
 * 预约工单 Service 接口
 *
 * @author 合房租赁
 */
public interface ReserveTicketService {

    /**
     * 创建预约工单
     *
     * @param userId
     * @param createReqVO 创建信息
     * @param from 1来自PC端 2来自租客端
     * @return 编号
     */
    Long createReserveTicket(Long userId, @Valid ReserveTicketCreateReqVO createReqVO, Integer from);

    /**
     * 更新预约工单
     *
     * @param userId
     * @param updateReqVO 更新信息
     * @param request
     */
    void updateReserveTicket(Long userId, @Valid ReserveTicketUpdateReqVO updateReqVO, HttpServletRequest request);

    /**
     * 删除预约工单
     *
     * @param id      编号
     * @param request
     */
    void deleteReserveTicket(Long id, HttpServletRequest request);

    /**
     * 获得预约工单
     *
     * @param id      编号
     * @param request
     * @return 预约工单
     */
    GetReserveTicketRespVO getReserveTicket(Long id, HttpServletRequest request);

    /**
     * 获得预约工单列表
     *
     * @param ids 编号
     * @return 预约工单列表
     */
    List<ReserveTicketDO> getReserveTicketList(Collection<Long> ids);

    /**
     * 获得预约工单分页
     *
     * @param pageReqVO 分页查询
     * @param request
     * @return 预约工单分页
     */
    PageResult<ReserveTicketRespVO> getReserveTicketPage(ReserveTicketPageReqVO pageReqVO, HttpServletRequest request);

    /**
     * 获得预约工单列表, 用于 Excel 导出
     *
     * @param exportReqVO 查询条件
     * @param request
     * @return 预约工单列表
     */
    List<ReserveTicketRespVO> getReserveTicketList(ReserveTicketExportReqVO exportReqVO, HttpServletRequest request);

    /**
     * 预约工单 - 分配跟进人
     *
     * @param loginUser
     * @param assignmentReqVO
     * @param request
     * @return
     */
    Long assignment(LoginUser loginUser, @Valid AssignmentReqVO assignmentReqVO, HttpServletRequest request);

    Boolean modifyProgress(Long userId, ModifyProgressReqVO modifyProgressReqVO);

    /**
     * 获取进度枚举 - 排除待处理,已签约
     * @return
     */
    List<GetProgressEnumRespVO> getProgressEnum();

    /**
     * 分页状态数量统计
     * @return
     */
    StatusCountRespVO statusCount(Integer status, HttpServletRequest request);

    /**
     * 个人中心-预约工单列表
     *
     * @param mobile
     * @param pageSize
     * @param pageNo
     * @return
     */
    PageResult<PersonalReserveRespVO> personalReservePage(@NonNull String mobile, Integer pageSize, Integer pageNo);

    /**
     * 租客端创建预约工单
     * @param userId
     * @param createReqVO
     * @return
     */
    Long tenantReserveTicket(Long userId, ReserveCreateReqVO createReqVO);

    /**
     * 租客端 - 我的预约
     *
     * @param mobile
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageResult<MyReserveTicketPageRespVO> myReserveTicketPage(String mobile, Integer pageNo, Integer pageSize);

    /**
     * 统计待完成预约工单总数
     * @return
     */
    GetTotalNumberRespVO getTotalNumber(Long userId);

    /**
     * 管家端 - 预约看房 和 紧急报修数量
     * @return
     */
    ReserveUrgentRepariNumRespVO reserveUrgentRepariNum();

    /**
     * 取消预约工单
     *
     * @param reserveTicketId 预约工单id
     * @param mobile
     * @return
     */
    Boolean cancelReserveTicket(Long reserveTicketId, String mobile);

    Map<Integer, Integer> remainingReserveQuantity(Long apartmentId, LocalDate reserveDate);
}
